#include <iostream>
#include <vector>
#include <algorithm>

bool cmp(std::pair<int, int> a, std::pair<int, int> b)
{
    if (a.first < b.first)
    {
        return true;
    }
    else if (a.first == b.first && a.second < b.second)
    {
        return true;
    }
    else
    {
        return false;
    }
}

int main()
{
    int n, k, x;
    std::cin >> n >> k >> x;

    std::vector<std::pair<int, int>> diff_vec;
    // std::vector<int> prices;
    for (int i = 0; i < n; i++)
    {
        int p;
        std::cin >> p;
        diff_vec.emplace_back(abs(p - x), p);
        // prices.push_back(p);
    }

    std::sort(diff_vec.begin(), diff_vec.end(), cmp);
    std::vector<int> result;
    for (int i = 0; i < k; i++)
    {
        result.push_back(diff_vec[i].second);
    }

    std::sort(result.begin(), result.end(), std::less<int>());

    for (int i = 0; i < k; i++)
    {
        std::cout << result[i] << " ";
    }

    return 0;
}